﻿using HalconDotNet;
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeaderCCSLaserUI.Models.VisionModels
{
    public class VM_PreProcessing : FunctionBase
    {
        public override bool Run(ref HObject ho_Image, string paramJson, ref HTuple hv_Row, ref HTuple hv_Column, ref HTuple hv_Angle, ref HTuple hv_Score, ref HObject maxRegion, ref HObject ho_SelectedRegion, ref HTuple v1, ref HTuple v2)
        {
            try
            {
                var MPreProcessingParam = JsonConvert.DeserializeObject<PreProcessingParam>(paramJson);
                if (MPreProcessingParam.IsUseEmphasize)
                {
                    HOperatorSet.Emphasize(ho_Image, out ho_Image, MPreProcessingParam.EmphasizeMaskWidth, MPreProcessingParam.EmphasizeMaskHeight, MPreProcessingParam.EmphasizeFactor);
                }
                return true;
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return false;
            }

        }
    }
}
